package com.smartcode.ai;


import com.smartcode.ai.entity.po.KnowledgePoint;
import com.smartcode.ai.entity.po.StudentLearningRecord;
import com.smartcode.ai.service.IKnowledgePointService;
import com.smartcode.ai.service.IStudentLearningRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
public class TeachingTools {

    private final IKnowledgePointService knowledgePointService;
    private final IStudentLearningRecordService learningRecordService;

    /**
     * 推送某课程的重点知识点
     */
    @Tool(description = "根据课程ID获取该课程的所有知识点，用于向学生推送学习内容")
    public List<KnowledgePoint> getKnowledgePointsByCourseId(
            @ToolParam(description = "课程ID") Integer courseId) {
        return knowledgePointService.listByCourseId(courseId);
    }

    /**
     * 记录学生学习情况
     */
    @Tool(description = "记录学生学习某个知识点的情况，包括掌握程度和笔记")
    public String recordStudentLearning(
            @ToolParam(description = "学生姓名") String studentName,
            @ToolParam(description = "课程名称") String courseName,
            @ToolParam(description = "知识点ID") Integer knowledgePointId,
            @ToolParam(description = "掌握程度：1-未掌握，2-部分掌握，3-已掌握") Integer masteryLevel,
            @ToolParam(description = "学习笔记，可为空") String notes) {
        return learningRecordService.saveLearningRecord(studentName, courseName, knowledgePointId, masteryLevel, notes);
    }

    /**
     * 查询学生在某课程的学习记录
     */
    @Tool(description = "查询学生在某课程中的学习历史记录")
    public List<StudentLearningRecord> getLearningRecords(
            @ToolParam(description = "学生姓名") String studentName,
            @ToolParam(description = "课程名称") String courseName) {
        return learningRecordService.listByStudentAndCourse(studentName, courseName);
    }
    @Tool(description = "测试用：返回固定知识点")
    public List<KnowledgePoint> testGetKnowledgePoints() {
        KnowledgePoint kp = new KnowledgePoint();
        kp.setTitle("测试知识点");
        kp.setContent("这是为了验证AI能否看到数据");
        return List.of(kp);
    }
}